import java.util.Arrays;
import java.util.List;

public class Solution88 {

    public static void main(String[] args) {

//        System.out.println(merge(48));
        int[] nums1 = new int[]{2, 0};
        int[] nums2 = new int[]{1};

        merge(nums1, 1, nums2, 1);
        System.out.println(Arrays.toString(nums1));
    }

    public static void merge(int[] nums1, int m, int[] nums2, int n) {
        int length = m + n;
        int[] temp = new int[length];
        int nums1Index = 0;
        int nums2Index = 0;
        for (int i = 0; i < length; i++) {
            if (m == 0 || nums1Index >= m) {
                temp[i] = nums2[nums2Index];
                nums2Index++;
            } else if (n == 0 || nums2Index >= n) {
                temp[i] = nums1[nums1Index];
                nums1Index++;
            } else if (nums2.length != 0 && nums1[nums1Index] <= nums2[nums2Index]) {
                temp[i] = nums1[nums1Index];
                nums1Index++;
            } else if (nums2.length != 0 && nums1[nums1Index] > nums2[nums2Index]) {
                temp[i] = nums2[nums2Index];
                nums2Index++;
            }

        }
        for (int i = 0; i < temp.length; i++) {
            nums1[i] = temp[i];
        }
    }

}
